// 存

function setCookie(key, value) {

var initDate = new Date();

initDate.setTime(initDate.getTime() + 30 * 60 * 1000);

document.cookie = key + "=" + value + ";expires=" + initDate.toGMTString() + ";path=/";

}

// 取

function getCookie(key) {

if (document.cookie.length > 0) {

var i = document.cookie.indexOf(key + "=")

if (i != -1) {

i = i + key.length + 1

var end = document.cookie.indexOf(";", i)

if (end == -1) end = document.cookie.length

return unescape(document.cookie.substring(i, end))

}

}

return undefined

}

//删

function removeCookie(key) {

var exp = new Date();

exp.setTime(exp.getTime() - 1);

var val = getCookie(key);

if (val != null) {

document.cookie = key + "=" + val + ";expires=" + exp.toGMTString();

}

}

export const Cookie = {

set: setCookie,

get: getCookie,

remove: removeCookie

}